package com.czy.owner.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.czy.owner.R;
import com.czy.owner.entity.CarBrandModel;

import java.util.List;

/**
 * Created by King on 2016/6/13 0013.
 */
public class PickLineAdapter extends BaseRecyclerAdapter<CarBrandModel,PickLineAdapter.PickLineHolder> implements RecyclerHeadersAdapter<RecyclerView.ViewHolder> {
    public PickLineAdapter(Context context, List<CarBrandModel> data) {
        super(context, data);
    }

    @Override
    public PickLineHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.item_pick_line_recycler, parent, false);
        return new PickLineHolder(view);
    }

    @Override
    public void onBindViewHolder(PickLineHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.bindData(data.get(position));
    }



    @Override
    public long getHeaderId(int position) {
        return data.get(position).getSuperCarBrandId();
    }

    @Override
    public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup parent) {
        View view = layoutInflater.inflate(R.layout.recycler_contacts_header, parent, false);
        return new RecyclerView.ViewHolder(view){};
    }

    @Override
    public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder, int position) {
        TextView textView = (TextView) holder.itemView.findViewById(R.id.tv_recycler_header);
        String showValue = data.get(position).getSuperCarBrandName();
        textView.setText(showValue);
    }
    public class PickLineHolder extends BaseRecyclerAdapter.ViewHolder {
        private TextView tvTitle;

        public PickLineHolder(View itemView) {
            super(itemView);
            tvTitle = (TextView) itemView.findViewById(R.id.tv_pick_line_item_title);
        }

        public void bindData(CarBrandModel mMembers) {
            tvTitle.setText(mMembers.getChName());
        }
    }
}
